﻿<?php if (!defined('SERVER_ROOT')) exit('No direct script access allowed');

class hoso_Model extends Model {

    function __construct(){
        parent::__construct();
    }

    /******************FORM dsp_all_hoso************************/
    public function SELECT_THU_TUC_DA_THUC_HIEN($arr_filter){
        $P_MA_CAN_BO = Session::get(TIEP_DAU_NGU_SESSION.'MA_CAN_BO');
        if (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') >0){
         $P_LOAI_CAN_BO = 'QUAN_TRI';
        }
        $P_NAM = $arr_filter['cbx_NAM'];
        return $this->db->ExecuteCursor("BEGIN TRACUU.SELECT_THU_TUC_DA_THUC_HIEN
                                                      (:CUR,
                                                       $P_MA_CAN_BO,
                                                      '$P_LOAI_CAN_BO',
                                                      '$P_NAM'
                                                      );END;",'CUR');
    }
    public function SELECT_THU_TUC_DETAIL_BY_TYPE($arr_filter){
        $P_TYPE = $arr_filter['hdn_TYPE_filter'];
        $P_TEN_TAT        = $arr_filter['txt_TEN_TAT_filter'];
        $P_MA_THU_TUC = $arr_filter['cbx_MA_THU_TUC_filter'];
        return $this->db->ExecuteCursor("BEGIN TRACUU.SELECT_THU_TUC_DETAIL_BY_TYPE
                                                      (:CUR,
                                                      '$P_TYPE',
                                                      '$P_TEN_TAT',
                                                      $P_MA_THU_TUC
                                                      );END;",'CUR');
    }
    public function DV_SELECT_MENU_SEARCH($arr_filter){
        $P_MA_CAN_BO = Session::get(TIEP_DAU_NGU_SESSION.'MA_CAN_BO');
        if (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') >0){
         $P_LOAI_CAN_BO = 'QUAN_TRI';
        }
        $P_MA_DON_VI_XU_LY = $arr_filter['cbx_MA_DON_VI_XU_LY'];
        $P_NAM = $arr_filter['cbx_NAM'];
        return $this->db->ExecuteCursor("BEGIN TRACUU.DV_SELECT_MENU_SEARCH
                                                      (:CUR,
                                                      '$P_MA_DON_VI_XU_LY',
                                                      '$P_NAM'
                                                      );END;",'CUR');
    }
    public function DV_SELECT_HS_SEARCH($arr_filter){
        $P_MA_CAN_BO = Session::get(TIEP_DAU_NGU_SESSION.'MA_CAN_BO');
        if (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') >0){
         $P_LOAI_CAN_BO = 'QUAN_TRI';
        }
        $P_TYPE = $arr_filter['hdn_TYPE_filter'];
        $P_TEN_TAT             = $arr_filter['txt_TEN_TAT_filter'];
        $P_MA_THU_TUC             = $arr_filter['cbx_MA_THU_TUC_filter'];
        $P_TRANG_THAI_HO_SO    = $arr_filter['hdn_TRANG_THAI_HO_SO_filter'];
        $P_SO_HO_SO            = $arr_filter['txt_SO_HO_SO'];
        $P_SO_BIEN_NHAN        = $arr_filter['txt_SO_BIEN_NHAN'];
        $P_TEN_CONG_DAN        = $arr_filter['txt_TEN_CONG_DAN'];
        $P_CMND_CONG_DAN       = $arr_filter['txt_CMND_CONG_DAN'];
        $P_DI_DONG_CONG_DAN    = $arr_filter['txt_DI_DONG_CONG_DAN'];
        $P_DIA_CHI_CONG_DAN    = $arr_filter['txt_DIA_CHI_CONG_DAN'];
        $P_VE_VIEC             = $arr_filter['txt_VE_VIEC'];
        $P_MA_DON_VI_TIEP_NHAN = $arr_filter['cbx_MA_DON_VI_TIEP_NHAN'];
        $P_NHAN_TU_NGAY        = $arr_filter['txt_NHAN_TU_NGAY'];
        $P_NHAN_DEN_NGAY       = $arr_filter['txt_NHAN_DEN_NGAY'];
        $P_HEN_TRA_TU_NGAY     = $arr_filter['txt_HEN_TRA_TU_NGAY'];
        $P_HEN_TRA_DEN_NGAY    = $arr_filter['txt_HEN_TRA_DEN_NGAY'];
        $P_MA_DON_VI_XU_LY = $arr_filter['cbx_MA_DON_VI_XU_LY'];
        return $this->db->ExecuteCursor("BEGIN TRACUU.DV_SELECT_HS_SEARCH
                                                      (:CUR,
                                                      '$P_MA_DON_VI_XU_LY',
                                                      '$P_TYPE',
                                                      '$P_TEN_TAT',
                                                      $P_MA_THU_TUC,
                                                      $P_TRANG_THAI_HO_SO,
                                                      '$P_SO_HO_SO',
                                                      '$P_SO_BIEN_NHAN',
                                                      '$P_TEN_CONG_DAN',
                                                      '$P_CMND_CONG_DAN',
                                                      '$P_DI_DONG_CONG_DAN',
                                                      '$P_DIA_CHI_CONG_DAN',
                                                      '$P_VE_VIEC',
                                                      '$P_MA_DON_VI_TIEP_NHAN',
                                                      '$P_NHAN_TU_NGAY',
                                                      '$P_NHAN_DEN_NGAY',
                                                      '$P_HEN_TRA_TU_NGAY',
                                                      '$P_HEN_TRA_DEN_NGAY'
                                                      );END;",'CUR');
    }
     public function DV_SELECT_HS_SEARCH_CHAM_TD($arr_filter){
        $P_MA_CAN_BO = Session::get(TIEP_DAU_NGU_SESSION.'MA_CAN_BO');
        if (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') >0){
         $P_LOAI_CAN_BO = 'QUAN_TRI';
        }
        $P_TYPE = $arr_filter['hdn_TYPE_filter'];
        $P_TEN_TAT             = $arr_filter['txt_TEN_TAT_filter'];
        $P_MA_THU_TUC             = $arr_filter['cbx_MA_THU_TUC_filter'];
        $P_TRANG_THAI_HO_SO    = $arr_filter['hdn_TRANG_THAI_HO_SO_filter'];
        $P_SO_HO_SO            = $arr_filter['txt_SO_HO_SO'];
        $P_SO_BIEN_NHAN        = $arr_filter['txt_SO_BIEN_NHAN'];
        $P_TEN_CONG_DAN        = $arr_filter['txt_TEN_CONG_DAN'];
        $P_CMND_CONG_DAN       = $arr_filter['txt_CMND_CONG_DAN'];
        $P_DI_DONG_CONG_DAN    = $arr_filter['txt_DI_DONG_CONG_DAN'];
        $P_DIA_CHI_CONG_DAN    = $arr_filter['txt_DIA_CHI_CONG_DAN'];
        $P_VE_VIEC             = $arr_filter['txt_VE_VIEC'];
        $P_MA_DON_VI_TIEP_NHAN = $arr_filter['cbx_MA_DON_VI_TIEP_NHAN'];
        $P_NHAN_TU_NGAY        = $arr_filter['txt_NHAN_TU_NGAY'];
        $P_NHAN_DEN_NGAY       = $arr_filter['txt_NHAN_DEN_NGAY'];
        $P_HEN_TRA_TU_NGAY     = $arr_filter['txt_HEN_TRA_TU_NGAY'];
        $P_HEN_TRA_DEN_NGAY    = $arr_filter['txt_HEN_TRA_DEN_NGAY'];
        $P_MA_DON_VI_XU_LY = $arr_filter['cbx_MA_DON_VI_XU_LY'];
        return $this->db->ExecuteCursor("BEGIN TRACUU.DV_SELECT_HS_SEARCH_CHAM_TD
                                                      (:CUR,
                                                      '$P_MA_DON_VI_XU_LY',
                                                      '$P_TYPE',
                                                      '$P_TEN_TAT',
                                                      $P_MA_THU_TUC,
                                                      $P_TRANG_THAI_HO_SO,
                                                      '$P_SO_HO_SO',
                                                      '$P_SO_BIEN_NHAN',
                                                      '$P_TEN_CONG_DAN',
                                                      '$P_CMND_CONG_DAN',
                                                      '$P_DI_DONG_CONG_DAN',
                                                      '$P_DIA_CHI_CONG_DAN',
                                                      '$P_VE_VIEC',
                                                      '$P_MA_DON_VI_TIEP_NHAN',
                                                      '$P_NHAN_TU_NGAY',
                                                      '$P_NHAN_DEN_NGAY',
                                                      '$P_HEN_TRA_TU_NGAY',
                                                      '$P_HEN_TRA_DEN_NGAY'
                                                      );END;",'CUR');
    }
     public function DV_SELECT_HS_SEARCH_TKQ_TH($arr_filter){
        $P_MA_CAN_BO = Session::get(TIEP_DAU_NGU_SESSION.'MA_CAN_BO');
        if (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') >0){
         $P_LOAI_CAN_BO = 'QUAN_TRI';
        }
        $P_TYPE = $arr_filter['hdn_TYPE_filter'];
        $P_TEN_TAT             = $arr_filter['txt_TEN_TAT_filter'];
        $P_MA_THU_TUC          = $arr_filter['cbx_MA_THU_TUC_filter'];
        $P_TRANG_THAI_HO_SO    = $arr_filter['hdn_TRANG_THAI_HO_SO_filter'];
        $P_SO_HO_SO            = $arr_filter['txt_SO_HO_SO'];
        $P_SO_BIEN_NHAN        = $arr_filter['txt_SO_BIEN_NHAN'];
        $P_TEN_CONG_DAN        = $arr_filter['txt_TEN_CONG_DAN'];
        $P_CMND_CONG_DAN       = $arr_filter['txt_CMND_CONG_DAN'];
        $P_DI_DONG_CONG_DAN    = $arr_filter['txt_DI_DONG_CONG_DAN'];
        $P_DIA_CHI_CONG_DAN    = $arr_filter['txt_DIA_CHI_CONG_DAN'];
        $P_VE_VIEC             = $arr_filter['txt_VE_VIEC'];
        $P_MA_DON_VI_TIEP_NHAN = $arr_filter['cbx_MA_DON_VI_TIEP_NHAN'];
        $P_NHAN_TU_NGAY        = $arr_filter['txt_NHAN_TU_NGAY'];
        $P_NHAN_DEN_NGAY       = $arr_filter['txt_NHAN_DEN_NGAY'];
        $P_HEN_TRA_TU_NGAY     = $arr_filter['txt_HEN_TRA_TU_NGAY'];
        $P_HEN_TRA_DEN_NGAY    = $arr_filter['txt_HEN_TRA_DEN_NGAY'];
        $P_MA_DON_VI_XU_LY = $arr_filter['cbx_MA_DON_VI_XU_LY'];
        return $this->db->ExecuteCursor("BEGIN TRACUU.DV_SELECT_HS_SEARCH_TKQ_TH
                                                      (:CUR,
                                                      '$P_MA_DON_VI_XU_LY',
                                                      '$P_TYPE',
                                                      '$P_TEN_TAT',
                                                      $P_MA_THU_TUC,
                                                      $P_TRANG_THAI_HO_SO,
                                                      '$P_SO_HO_SO',
                                                      '$P_SO_BIEN_NHAN',
                                                      '$P_TEN_CONG_DAN',
                                                      '$P_CMND_CONG_DAN',
                                                      '$P_DI_DONG_CONG_DAN',
                                                      '$P_DIA_CHI_CONG_DAN',
                                                      '$P_VE_VIEC',
                                                      '$P_MA_DON_VI_TIEP_NHAN',
                                                      '$P_NHAN_TU_NGAY',
                                                      '$P_NHAN_DEN_NGAY',
                                                      '$P_HEN_TRA_TU_NGAY',
                                                      '$P_HEN_TRA_DEN_NGAY'
                                                      );END;",'CUR');
    }
     public function DV_SELECT_HS_SEARCH_TKQ_QH($arr_filter){
        $P_MA_CAN_BO = Session::get(TIEP_DAU_NGU_SESSION.'MA_CAN_BO');
        $P_TYPE = $arr_filter['hdn_TYPE_filter'];
        $P_TEN_TAT             = $arr_filter['txt_TEN_TAT_filter'];
        $P_MA_THU_TUC          = $arr_filter['cbx_MA_THU_TUC_filter'];
        $P_TRANG_THAI_HO_SO    = $arr_filter['hdn_TRANG_THAI_HO_SO_filter'];
        $P_SO_HO_SO            = $arr_filter['txt_SO_HO_SO'];
        $P_SO_BIEN_NHAN        = $arr_filter['txt_SO_BIEN_NHAN'];
        $P_TEN_CONG_DAN        = $arr_filter['txt_TEN_CONG_DAN'];
        $P_CMND_CONG_DAN       = $arr_filter['txt_CMND_CONG_DAN'];
        $P_DI_DONG_CONG_DAN    = $arr_filter['txt_DI_DONG_CONG_DAN'];
        $P_DIA_CHI_CONG_DAN    = $arr_filter['txt_DIA_CHI_CONG_DAN'];
        $P_VE_VIEC             = $arr_filter['txt_VE_VIEC'];
        $P_MA_DON_VI_TIEP_NHAN = $arr_filter['cbx_MA_DON_VI_TIEP_NHAN'];
        $P_NHAN_TU_NGAY        = $arr_filter['txt_NHAN_TU_NGAY'];
        $P_NHAN_DEN_NGAY       = $arr_filter['txt_NHAN_DEN_NGAY'];
        $P_HEN_TRA_TU_NGAY     = $arr_filter['txt_HEN_TRA_TU_NGAY'];
        $P_HEN_TRA_DEN_NGAY    = $arr_filter['txt_HEN_TRA_DEN_NGAY'];
        $P_MA_DON_VI_XU_LY = $arr_filter['cbx_MA_DON_VI_XU_LY'];
        return $this->db->ExecuteCursor("BEGIN TRACUU.DV_SELECT_HS_SEARCH_TKQ_QH
                                                      (:CUR,
                                                      '$P_MA_DON_VI_XU_LY',
                                                      '$P_TYPE',
                                                      '$P_TEN_TAT',
                                                      $P_MA_THU_TUC,
                                                      $P_TRANG_THAI_HO_SO,
                                                      '$P_SO_HO_SO',
                                                      '$P_SO_BIEN_NHAN',
                                                      '$P_TEN_CONG_DAN',
                                                      '$P_CMND_CONG_DAN',
                                                      '$P_DI_DONG_CONG_DAN',
                                                      '$P_DIA_CHI_CONG_DAN',
                                                      '$P_VE_VIEC',
                                                      '$P_MA_DON_VI_TIEP_NHAN',
                                                      '$P_NHAN_TU_NGAY',
                                                      '$P_NHAN_DEN_NGAY',
                                                      '$P_HEN_TRA_TU_NGAY',
                                                      '$P_HEN_TRA_DEN_NGAY'
                                                      );END;",'CUR');
    }

    /**************FORM dsp_single_hoso***************/
    public function qry_single_hoso($P_MA_HO_SO){
        return $this->db->ExecuteCursor("BEGIN HOSO.SELECT_HO_SO_DETAIL
                                                      (:CUR,
                                                      $P_MA_HO_SO
                                                      );END;",'CUR');
    }
    public function qry_all_filehoso($P_MA_HO_SO){
        return $this->db->ExecuteCursor("BEGIN HOSO.SELECT_FILE_HO_SO
                                                      (:CUR,
                                                      $P_MA_HO_SO
                                                      );END;",'CUR');
    }
    public function qry_all_giayto_byhoso($P_MA_HOSO) {
        return $this->db->ExecuteCursor("BEGIN HOSO_LINH.SELECT_DM_GIAYTO_BY_HOSO
                                                      (:CUR,
                                                      '$P_MA_HOSO'
                                                      );END;", 'CUR');
    }

    /**************FORM dsp_qths***************/
      public function SELECT_BUOC_HS_BY_MHS_TRACUU($P_MA_HO_SO){
        return $this->db->ExecuteCursor("BEGIN TRACUU.SELECT_BUOC_HS_BY_MHS_TRACUU
                                                      (:CUR,
                                                      $P_MA_HO_SO
                                                      );END;",'CUR');
    }
     public function SELECT_CAN_BO_CUA_CVHS($P_MA_TO_CHUYEN_MON,$MA_CONG_VIEC_HO_SO){
        return $this->db->ExecuteCursor("BEGIN TRACUU.SELECT_CAN_BO_CUA_CVHS
                                                      (:CUR,
                                                      $P_MA_TO_CHUYEN_MON,
                                                      $MA_CONG_VIEC_HO_SO
                                                      );END;",'CUR');
    }
     public function SELECT_CAN_BO_CUA_LOAI_NNSD2($P_MA_LOAI_NHOM_NSD,$MA_HO_SO){
        return $this->db->ExecuteCursor("BEGIN TRACUU.SELECT_CAN_BO_CUA_LOAI_NNSD2
                                                      (:CUR,
                                                      '$P_MA_LOAI_NHOM_NSD',
                                                      $MA_HO_SO
                                                      );END;",'CUR');
    }
}